package com.theima.mytreeset;

/**
 * @program: Myset
 * @description:
 * @author: xuejingjing
 * @create: 2021-06-08 21:47
 **/

import java.util.TreeSet;

/**
 * TreeSet集合用来存储Student类型,实现按照对象的年龄排序
 */
public class MyTreeSet2 {
    public static void main(String[] args) {

        TreeSet<Student> ts = new TreeSet<>();
        Student  s1 = new Student("小花",28);
        Student  s2 = new Student("小刚",27);
        Student  s3 = new Student("小李",29);
        Student  s4 = new Student("小黑",28);

        ts.add(s1);
        ts.add(s2);
        ts.add(s3);
        ts.add(s4);


        System.out.println(ts);



    }
}
